﻿<%@ Page Title="调拨结果" Language="C#" MasterPageFile="~/master/m.master" %>

<script runat="server"></script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../assets/css/shelf/base.css" rel="stylesheet">
    <link href="../assets/css/plugins/boxdrop/boxDrop.css" rel="stylesheet" />
    <style type="text/css">
        .condition {
            padding: 2px 0;
        }
    </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="main" runat="Server">
    <div class="system-box">
        <div class="right-side">
            <div class="btns-container">
                <div class="modal inmodal" id="addWindow" tabindex="-1" role="dialog" aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content animated bounceInRight">
                            <div class="modal-header">
                                <span class="editTitle"></span>
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span> <span class="sr-only">关闭</span> </button>
                            </div>
                            <div id="message" style="display: none"></div>
                            <div class="modal-body clearfix">
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <label for="CompanyId" class="col-sm-2 control-label">公司编码</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="CompanyId" name="CompanyId" placeholder="KM" class="form-control" readonly="readonly" value="KM" />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="BillNo" class="col-sm-2 control-label">生产订单</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="BillNo" name="BillNo" placeholder="请输入生产订单" datacol="yes" err="请输入生产订单" checkexpession="NotNull" class="form-control required" />
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="Warehouse" class="col-sm-2 control-label">仓库</label>
                                        <div class="col-sm-10">
                                            <table id="Warehouse" class=" table table-bordered " width="100%" style="margin-top: 0 !important; border: 0; border-bottom: 1px solid #ebebeb;">
                                            </table>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" id="addModuleBtn" class="btn btn-primary">保存</button>
                                <button type="button" id="closeAddBox" class="btn btn-white" data-dismiss="modal">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="condition clearfix">
                <label>店铺</label>
                <input type="text" placeholder="店铺代码或名称" id="search-store" hidden data-value="" />
            </div>

            <div class="right-content-box">
                <div class="ibox-content">
                    <table class="footable table table-stripped">
                        <thead></thead>
                        <tbody id="pageList"></tbody>
                    </table>
                </div>
            </div>

            <div class="pageControl"></div>
        </div>
    </div>

</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" runat="Server">
    <script src="../assets/js/page/pageControl.js"></script>
    <script src="../assets/js/page/rScroll.js"></script>
    <script src="../assets/js/page/tableControl.js"></script>
    <script src="../assets/js/plugins/boxdrop/jquery.boxdrop.js"></script>    
    <script src="../assets/js/framework.js"></script>
    <script>
        $('document').ready(function () {
            //模块ID
            var ModuleID = Y.getUrlParam("ModuleID");
            //当前页数
            var page = 1;
            commonUtil.loadBtnList(ModuleID, function () {
                $('#editBtn').attr("disabled", "disabled");
                $('#deleteBtn').attr("disabled", "disabled");
                rScroll();
            });

            var dataList = [];
            //处理表头
            if ($('.footable thead').children().size() == 0) {
                tableControl.initThead('.footable',
                    [
                        {
                            trClass: '',
                            children: [
                                { tdText: '序号', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '店铺', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w150' },
                                { tdText: '调出SKC数', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '调出量', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                                { tdText: '调入量', c: 0, r: 0, tdHtml: '', tdId: '', tdClass: 'diy-td-w50' },
                            ]
                        }
                    ]);
            }

            var pageList = [];
            //获取列表
            var loadList = function () {
                $('#editBtn').attr('disabled', 'disabled');
                $('#deleteBtn').attr('disabled', 'disabled');

                shopCode = '';
                materialID = '';
                sizeID = '';

                pageControl.init('NewOdsErpTmpCalcStock', 'TotalMvJobMessage', {
                    ShopIDs: $('#search-store').val().trim().replace(/'/g, ''),
                    Page: page,
                    Size: 50,
                    needLayer: true,
                    alwaysCallBack: function () {
                        $('#pageList').empty();
                    }
                }, function (result) {
                    pageList = [];
                    page = result.page;
                    var tBody = [];
                    if (!Y.checkNull(result.data)) {
                        if (result.data.length > 0) {
                            dataList = result.data;
                            var IsEmpty = '0';
                            result.data.map(function (items, i) {
                                var tempChild = [];
                                tempChild.push({
                                    tdText: '', c: 0, r: 0,
                                    tdHtml: '<span style="display:inline-block; width:30px;">' +
                                    (i + 1 || IsEmpty) +
                                    '</span>',
                                    tdId: '', tdClass: 'Index'
                                });
                                tempChild.push({
                                    tdText: '', c: 0, r: 0,
                                    tdHtml: '<span style="display:inline-block; width:150px;">' +
                                    (items.ShopName || IsEmpty) +
                                    '</span>',
                                    tdId: '', tdClass: 'ShopName'
                                });
                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:50px;">' + (items.outCountSKC || IsEmpty) + '</span>',
                                    tdId: '',
                                    tdClass: 'outCountSKC'
                                });
                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:50px;">' + (items.outSum || IsEmpty) + '</span>',
                                    tdId: '',
                                    tdClass: 'outSum'
                                });
                                tempChild.push({
                                    tdText: '',
                                    c: 0,
                                    r: 0,
                                    tdHtml: '<span style="display:inline-block; width:50px">' + (items.inSum || IsEmpty) + '</span>',
                                    tdId: '',
                                    tdClass: 'inSum'
                                });
                                var tempTr = {
                                    trClass: (i % 2 == 0 ? 'gradeX footable-even' : 'gradeX footable-odd') + ' ' + i,
                                    children: tempChild
                                };
                                tBody.push(tempTr);
                            });
                        }
                        rScroll();
                    }
                    tableControl.initTbody('.footable', (tBody.length > 0 ? tBody : null), 13, null);

                });
            }
            
            $('#search-store').boxDrop({ width: 160 });
            $('search-store').on("boxdrop-open", function () {
                $('#search-store').boxDrop("load", { ParentAreaID: $("#search-commodity").val(), ProID: $("#serarch-province").val(), CityID: $("#serarch-city").val() });
            });


            //选中记录
            $('#pageList').on('click',
                'tr',
                function () {

                    $('.footable tr').removeClass('check');

                    var trClass = $(this).attr("class");
                    trClass = trClass.replace(/gradeX /, "");
                    trClass = trClass.replace(/footable-even /, "");
                    trClass = trClass.replace(/footable-odd /, "");
                    trClass = '.' + trClass;
                    $(trClass).addClass("check");

                });

            //查询按钮
            $('.btns-container').on('click', '#btn-search', function () {
                page = 1;
                loadList();
            });


            //导出
            $(document).on("click", "#exportBtn", function () {
                var conditionsArr = [];
                var UserID = JSON.parse(window.sessionStorage.getItem('login-info'));
                if (!Y.checkNull(UserID))
                    userId = UserID.UserId;
                conditionsArr.push({ connector: "and", column: "Operator", operator: "=", value: userId });
                conditionsArr = JSON.stringify(conditionsArr);
                var tempParam = {};
                tempParam.filename = "调拨结果";
                tempParam.filetype = "NEWMVJOBMESSAGE";
                tempParam.conditions = encodeURIComponent(conditionsArr);;
                var t = $.Export(tempParam);
            });

            loadList();
        });




    </script>
</asp:Content>
